home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- char include[] = "#include";
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- FILE *fin, *fout, *fwork;
- char ext[20], buf[512], *cp, *cp1;
-
- if(argc < 3 || argc > 4) {
- printf("mkdep.exe - syntax: mkdep <infile> <outfile> [ext]\n");
- exit(1);
- return 0;
- }
-
- if((fin = fopen(argv[1],"r")) == NULL
- || (fout = fopen(argv[2],"w")) == NULL) {
- printf("File reading/creating error\n");
- exit(1);
- return 0;
- }
-
- if(argc > 3)
- strcpy(ext,strlwr(argv[3]));
- else
- strcpy(ext,".c");
-
- while(fgets(buf,512,fin) != NULL) {
- if((cp = strchr(buf,' ')) == NULL)
- continue;
- *cp = '\0';
-
- strlwr(buf);
- fprintf(fout,"%s.obj: %s%s",buf,buf,ext);
-
- strcat(buf,ext);
-
- if((fwork = fopen(buf,"r")) == NULL) {
- printf("Unable to open file %s\n",buf);
- continue;
- }
- while(fgets(buf,512,fwork) != NULL){
- if(strncmp(buf,include,sizeof(include)-1) != 0)
- continue;
- if((cp = strchr(buf,'\"')) == NULL)
- continue;
- cp++;
- if((cp1 = strchr(cp,'\"')) == NULL)
- continue;
- fputc(' ',fout);
- while(cp != cp1)
- fputc(*cp++,fout);
- }
- fputc('\n',fout);
- fflush(fout);
- fclose(fwork);
- }
- fclose(fin);
- fclose(fout);
- return 0;
- }